<?php

class Upload extends Controller {
	
	function Upload()
	{
		parent::Controller();
		$this->load->helper(array('form', 'url'));
	}
	
	function index()
	{	
		$this->load->view('upload_form', array('error' => ' ' ));
	}

	function do_upload()
	{
		$config['upload_path'] = "./km_resource/cops_group/file_uploads";
		$config['allowed_types'] = 'doc|docx|docm|dotx|dotm|pptx|pptm|pdf|txt|htm|html|zip|gif|png|jpg';	//file allow
			$config['max_size']	= '1024';	//1mb
			$config['overwrite'] = TRUE;
			$config['remove_spaces'] = TRUE;	//replace with underscore
			$config['encrypt_name'] = TRUE;	//encrtyp file name :)
			
		
		$this->load->library('upload', $config);
	
		if ( ! $this->upload->do_upload())
		{
			$error = array('error' => $this->upload->display_errors());
			
			$this->load->view('upload_form', $error);
		}	
		else
		{
			$data = array('upload_data' => $this->upload->data());
			
			$this->load->view('upload_success', $data);
		}
	}	
}
?>